//
//  CommonPublicityItemCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/10/22.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "CommonPublicityItemCell.h"

#import "ArticleListData.h"

@interface CommonPublicityItemCell ()

/// viewModle
@property (nonatomic, readwrite, strong) CommonPublicityItemViewModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* contentLabel;
@property (weak, nonatomic) IBOutlet UILabel* nameLabel;
@property (weak, nonatomic) IBOutlet UILabel* publishDateLabel;
@property (weak, nonatomic) IBOutlet UILabel* projectAddrLabel;
@property (weak, nonatomic) IBOutlet UIImageView* avatarImgView;

@end

@implementation CommonPublicityItemCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(CommonPublicityItemViewModel *)viewModel
{
    self.viewModel = viewModel;
    
    ArticleListData* data = viewModel.data;
    
//    NSDateFormatter* format = [[NSDateFormatter alloc] init];
//    [format setDateFormat:@"yyyy-MM-dd"];
//    NSDate *fromdate = [format dateFromString:[NSString stringWithFormat:@"2018年%@", data.addTime]];
//    NSString* strAddTime = [fromdate mh_string_yyyy_MM_dd];
    
    self.contentLabel.text = data.title;
    self.nameLabel.text = @"用户名";
    self.publishDateLabel.text = HCStrFormat(@"发布日期：%@", data.addTime);
    self.projectAddrLabel.text = HCStrFormat(@"项目地址：%@", data.areaName);
    
    @weakify(self);
    [[self rac_signalForSelector:@selector(layoutSubviews)] subscribeNext:^(id x)
     {
         @strongify(self);
         
         self.avatarImgView.layer.cornerRadius = self.avatarImgView.frame.size.width/2.0f;
         self.avatarImgView.layer.masksToBounds = YES;
         //    [self.aImgView yy_setImageWithURL:[NSURL URLWithString:curUserData.icon] placeholder:MHImageNamed(@"placeholderLogo")];
     }];
}

@end
